﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using QXBook.Service;
using QXBook.Model;
using QXBook.Controls.HtmlControls;
using QXBook.Utils;
using Web.App_Code;

namespace Web
{
    public partial class _Default : UserBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = "";
            if (!Page.IsPostBack)
            {
                this.TextBind();
            }
        }

        private void TextBind()
        {
            #region 视频

            #endregion

            #region 资讯
            List<ArticleInfo> list = ServiceFactory.CreateInstance<ArticleService>().GetTopList(4);

            rptArticle.DataSource = list;
            rptArticle.DataBind();
            #endregion
        }

        protected void rptArticle_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            ArticleInfo article = (ArticleInfo)e.Item.DataItem;
            Anchor aTitle = (Anchor)e.Item.FindControl("aTitle");
            Literal lAddDate = (Literal)e.Item.FindControl("lAddDate");

            aTitle.Text = article.Title;
            aTitle.Href = "Article/Article_View.aspx?ArticleID=" + CommonUtils.UrlEncode(article.ArticleID.ToString());
            lAddDate.Text = article.AddDate.ToString("yyyy-MM-dd");
        }
    }
}
